package com.luosl.akhasi.lucence.ik;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.lionsoul.jcseg.analyzer.JcsegAnalyzer;
import org.lionsoul.jcseg.tokenizer.core.JcsegTaskConfig;

import java.io.IOException;

/**
 * Created by Administrator on 2016/4/8.
 */
public class Test {
    public static void main(String[] args) throws IOException {
        Analyzer ik = new JcsegAnalyzer(JcsegTaskConfig.SIMPLE_MODE);
        JcsegAnalyzer jcsegAnalyzer=(JcsegAnalyzer)ik;
        JcsegTaskConfig config = jcsegAnalyzer.getTaskConfig();
        //追加同义词到分词结果中, 需要在jcseg.properties中配置jcseg.loadsyn=1
        config.setAppendCJKSyn(true);
        //追加拼音到分词结果中, 需要在jcseg.properties中配置jcseg.loadpinyin=1
        config.setAppendCJKPinyin(true);
        TokenStream ts = ik.tokenStream("name", "春的森林");
        ts.reset();
        CharTermAttribute term=ts.getAttribute(CharTermAttribute.class);
        while(ts.incrementToken()){
            System.out.println(term.toString());
        }
    }
}
